package cn.socialcredits.activity.data.implicits

import cn.socialcredits.activity.data.domain.RegisterActivity
import cn.socialcredits.activity.data.model.ActivityRegistration
import cn.socialcredits.activity.setting.{EmailSetting, MongoSetting}
import play.api.libs.json._
import reactivemongo.bson.BSONObjectID

trait JSONImplicits {
  implicit def __bsonObjectIdFormats = new Format[BSONObjectID] {
    override def writes(o: BSONObjectID): JsValue = JsString(o.stringify)

    override def reads(json: JsValue): JsResult[BSONObjectID] = JsSuccess(BSONObjectID(json.as[String]))
  }

  implicit def __emailSettingFormats = Json.format[EmailSetting]

  implicit def __mongoSettingFormats = Json.format[MongoSetting]

  implicit def __registerActivityFormats = Json.format[RegisterActivity]

  implicit def __activityRegistrationFormats = Json.format[ActivityRegistration]
}

object JSONImplicits extends JSONImplicits
